package Live

import (
	u "live_record_app/utils"

	"github.com/gin-gonic/gin"
)

type webHookData struct {
	EventType      string `json:"EventType"`
	EventTimestamp string `json:"EventTimestamp"`
	EventId        string `json:"EventId"`
	EventData      struct {
		SessionId        string  `json:"SessionId"`
		RoomId           int     `json:"RoomId"`
		ShortId          int     `json:"ShortId"`
		Name             string  `json:"Name"`
		Title            string  `json:"Title"`
		AreaNameParent   string  `json:"AreaNameParent"`
		AreaNameChild    string  `json:"AreaNameChild"`
		Recording        bool    `json:"Recording"`
		Streaming        bool    `json:"Streaming"`
		DanmakuConnected bool    `json:"DanmakuConnected"`
		RelativePath     string  `json:"RelativePath"`
		FileOpenTime     string  `json:"FileOpenTime"`
		FileCloseTime    string  `json:"FileCloseTime"`
		FileSize         int     `json:"FileSize"`
		Duration         float32 `json:"Duration"`
	} `json:"EventData"`
}

var log = u.LoadLogs("logs/live", "live.log")

func BiliLiveRecordRobotWebhook(c *gin.Context) {
	var param webHookData
	c.BindJSON(&param)
	switch param.EventType {
	case "SessionStarted":
	case "FileOpening":
	case "FileClosed":
		log.Info("路径:", param.EventData.RelativePath)
	case "SessionEnded":
	case "StreamStarted":
	case "StreamEnded":
	default:
		return
	}
}
